﻿@using System.Data;
@model DTcms.Model.BaseModel
@{
    ViewBag.Title = "会员中心-" + Model.site.name;
    string action = Model.info["action"].ToString();
}
@section HeaderContent{

}
<!--当前位置-->
<div class="section">
    <div class="location">
        <span>当前位置：</span>
        <a href="@Html.linkurl("index")">首页</a> &gt;
        <a href="@Html.linkurl("usercenter","index")">会员中心</a>
    </div>
</div>
<!--/当前位置-->

<div class="section clearfix">
    <!--页面左边-->
    @Html.Partial("_ucenter_nav")
    <!--/页面左边-->
    <!--页面左边-->
    <div class="right-auto">
        <div class="bg-wrap" style="min-height:765px;">
            @if (action == "index")
            {
                var groupModel = (DTcms.Model.user_groups)Model.info["groupModel"];
                string curr_login_ip = Model.info["curr_login_ip"].ToString();
                string pre_login_ip = Model.info["pre_login_ip"].ToString();
                string pre_login_time = Model.info["pre_login_time"].ToString();
                string total_order = Model.info["total_order"].ToString();
                string total_msg = Model.info["total_msg"].ToString();
                <!--会员中心-->
                <div class="sub-tit">
                    <a class="add" href="javascript:history.go(-1);"><i class="iconfont icon-reply"></i>返回</a>
                    <ul>
                        <li class="selected">
                            <a href="javascript:;">个人中心</a>
                        </li>
                    </ul>
                </div>

                <div class="center-head clearfix">
                    <div class="img-box">
                        @if (Model.userModel.avatar != "")
                        {
                            <img src="@Model.userModel.avatar" />
                        }
                        else
                        {
                            <i class="iconfont icon-user-full"></i>
                        }
                    </div>
                    <div class="list-box">
                        <h3>欢迎您~ @Model.userModel.user_name</h3>
                        <ul>
                            <li>组别：@groupModel.title</li>
                            <li>账户余额：￥@Model.userModel.amount</li>
                            <li><p><a href="#">消费记录</a></p></li>
                            <li>账户成长值：@Model.userModel.exp</li>
                            <li>账户积分：@Model.userModel.point</li>
                            <li><p><a class="link-btn" href="@Html.linkurl("useramount", "recharge")">立即充值</a></p></li>
                        </ul>
                    </div>
                </div>
                <div class="center-info clearfix">
                    <ul>
                        <li>本次登录IP：@curr_login_ip</li>
                        <li>上次登录IP：@pre_login_ip</li>
                        <li>注册时间：@Model.userModel.reg_time</li>
                        <li>上次登录时间：@pre_login_time</li>
                    </ul>
                </div>

                <div class="center-tit">
                    <span><a href="@Html.linkurl("userorder", "list")">更多..</a></span>
                    <h3><i class="iconfont icon-order"></i>我的订单</h3>
                </div>
                <div class="center-info clearfix">
                    <ul>
                        <li>已完成订单：@Html.get_user_order_count("status=3 and user_id=" + Model.userModel.id)个</li>
                        <li>待完成订单：@Html.get_user_order_count("status<3 and user_id=" + Model.userModel.id)个</li>
                    </ul>
                </div>
                <div class="center-tit">
                    <span><a href="@Html.linkurl("usermessage", "accept")">更多..</a></span>
                    <h3><i class="iconfont icon-comment"></i>站内消息</h3>
                </div>

                <div class="table-wrap">
                    <table class="layui-table" lay-data="{page:false, id:'ltable'}" lay-filter="ltable">
                        <thead>
                            <tr>
                                <th lay-data="{field:'title',templet:'#title'}">标题</th>
                                <th lay-data="{field:'is_read',templet:'#is_read'}">状态</th>
                                <th lay-data="{field:'post_time'}">时间</th>
                            </tr>
                        </thead>
                    </table>
                    <script type="text/html" id="title">
                        <a href="">{{d.title}}</a> (发件人：{{d.post_user_name}})
                    </script>
                    <script type="text/html" id="is_read">
                        {{d.is_read==1?'已读' : '未读'}}
                    </script>
                </div>
                <script type="text/javascript">
                    layui.use(['myaspx'], function () {
                        var os = layui.myaspx;

                        // 渲染表格
                        os.dataBind('/api/lisence_ajax/get_user_message_list', { action: "index", limit: 5 },false);
                    });
                </script>
                <!--会员中心-->
            }
            else if (action == "password")
            {
                <!--修改密码-->
                <div class="sub-tit">
                    <a class="add" href="@Html.linkurl("usercenter", "index")"><i class="iconfont icon-reply"></i>返回</a>
                    <ul>
                        <li class="selected">
                            <a href="javascript:;">修改密码</a>
                        </li>
                    </ul>
                </div>

                <form name="pwdForm" id="pwdForm" url="/api/lisence_ajax/user_password_edit">
                    <div class="form-box">
                        <dl class="form-group">
                            <dt>用户名：</dt>
                            <dd>@Model.userModel.user_name</dd>
                        </dl>
                        <dl class="form-group">
                            <dt>旧密码：</dt>
                            <dd>
                                <input name="txtOldPassword" id="txtOldPassword" type="password" class="input" datatype="*6-20" nullmsg="请输入旧密码" errormsg="密码范围在6-20位之间" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>新密码：</dt>
                            <dd>
                                <input name="txtPassword" id="txtPassword" type="password" class="input" datatype="*6-20" nullmsg="请输入新密码" errormsg="密码范围在6-20位之间" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>确认新密码：</dt>
                            <dd>
                                <input name="txtPassword1" id="txtPassword1" type="password" class="input" datatype="*" recheck="txtPassword" nullmsg="请再输入一次新密码" errormsg="两次输入的密码不一致" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dd>
                                <input id="btnSubmit" name="btnSubmit" type="submit" value="确认修改" class="submit" />
                            </dd>
                        </dl>
                    </div>
                </form>
                <script type="text/javascript">
                    layui.use(['validform', 'jqueryform'], function () {
                        $("#pwdForm").initValidform('#btnSubmit', 1);
                    });
                </script>
                <!--/修改密码-->
            }
            else if (action == "proinfo")
            {
                <!--修改资料-->
                <script type="text/javascript" charset="utf-8" src="/scripts/jquery/PCASClass.js"></script>
                <div class="sub-tit">
                    <a class="add" href="@Html.linkurl("usercenter", "index")"><i class="iconfont icon-reply"></i>返回</a>
                    <ul>
                        <li class="selected">
                            <a href="javascript:;">账户资料</a>
                        </li>
                    </ul>
                </div>
                <form name="infoForm" id="infoForm" url="/api/lisence_ajax/user_info_edit" class="layui-form">
                    <div class="form-box">
                        <dl class="form-group">
                            <dt>用户名：</dt>
                            <dd>
                                @Model.userModel.user_name
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>昵称：</dt>
                            <dd>
                                <input name="txtNickName" id="txtNickName" type="text" class="input" value="@Model.userModel.nick_name" datatype="*" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>性别：</dt>
                            <dd>
                                <input type="radio" name="rblSex" value="男" title="男" @(Model.userModel.sex == "男" ? "checked" : "")>
                                <input type="radio" name="rblSex" value="女" title="女" @(Model.userModel.sex == "女" ? "checked" : "")>
                                <input type="radio" name="rblSex" value="保密" title="保密" @(Model.userModel.sex == "保密" ? "checked" : "")>
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>生日：</dt>
                            <dd>
                                <input name="txtBirthday" id="txtBirthday" type="text" class="input" maxlength="30" value="@Html.datetostr(Model.userModel.birthday, "yyyy-M-d")" />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>邮箱：</dt>
                            <dd>
                                <input name="txtEmail" id="txtEmail" type="text" class="input" value="@Model.userModel.email" datatype="e" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>手机：</dt>
                            <dd>
                                <input name="txtMobile" id="txtMobile" type="text" class="input" value="@Model.userModel.mobile" datatype="m" sucmsg=" " />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>电话：</dt>
                            <dd>
                                <input name="txtTelphone" id="txtTelphone" type="text" class="input" maxlength="30" value="@Model.userModel.telphone" />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>所属地区：</dt>
                            <dd>
                                <select id="txtProvince" name="txtProvince" class="select" lay-ignore></select>
                                <select id="txtCity" name="txtCity" class="select" lay-ignore></select>
                                <select id="txtArea" name="txtArea" class="select" datatype="*" sucmsg=" " lay-ignore></select>
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>详细地址：</dt>
                            <dd>
                                <input name="txtAddress" id="txtAddress" type="text" class="input" maxlength="250" value="@Model.userModel.address" />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>在线QQ：</dt>
                            <dd>
                                <input name="txtQQ" id="txtQQ" type="text" class="input" maxlength="20" value="@Model.userModel.qq" />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dt>MSN账户：</dt>
                            <dd>
                                <input name="txtMsn" id="txtMsn" type="text" class="input" maxlength="20" value="@Model.userModel.msn" />
                            </dd>
                        </dl>
                        <dl class="form-group">
                            <dd>
                                <input id="btnSubmit" name="btnSubmit" type="submit" value="确认修改" class="submit" />
                            </dd>
                        </dl>
                    </div>
                </form>
                <script type="text/javascript">
                    layui.use(['validform', 'jqueryform','laydate','form'], function () {
                        var laydate=layui.laydate;
                        laydate.render({
                            elem: '#txtBirthday'
                        });
                        //初始化地区
                        var mypcas = new PCAS("txtProvince,所属省份", "txtCity,所属城市", "txtArea,所属地区");
                        var areaArr = ("@Model.userModel.area").split(",");
                        if (areaArr.length == 3) {
                          mypcas.SetValue(areaArr[0], areaArr[1], areaArr[2]);
                        }
                        $("#infoForm").initValidform('#btnSubmit', 1);
                    });
                </script>
                <!--/修改资料-->
            }
            else if (action == "avatar")
            {
                <!--设置头像-->
                <div class="sub-tit">
                    <a class="add" href="@Html.linkurl("usercenter", "index")"><i class="iconfont icon-reply"></i>返回</a>
                    <ul>
                        <li class="selected">
                            <a href="javascript:;">设置头像</a>
                        </li>
                    </ul>
                </div>
                <div class="form-box">
                    <div id="upload-box" class="upload-box"></div>
                    <div class="cropper-wrap">
                        <div class="cropper-box">
                            <img id="target" src="@Model.templateskin/images/avatar-bg.png" width="350" height="350" />
                        </div>
                        <div class="cropper-view">
                            <div class="img-box">
                                <img id="preview" src="@(Html.get_user_avatar(Model.userModel.id))" />
                                <span>头像预览</span>
                            </div>
                            <div class="btn-box">
                                <p><strong>头像预览区</strong></p>
                                <p><button id="btnSubmit" class="layui-btn layui-btn-normal icon-btn"><i class="layui-icon">&#xe60d;</i>裁剪图片</button></p>
                                <p class="tip">提示：生成头像大小180*180相素上传图片后，左侧选取图片合适大小，点击下面的保存按钮。</p>
                            </div>
                        </div>
                    </div>
                </div>
                <script type="text/javascript">
                    layui.use(['myaspx'], function () {
                        var $ = layui.jquery, os = layui.myaspx;
                        // 裁剪图片弹窗
                        $('#btnSubmit').click(function () {
                            os.cropImg({
                                imgSrc: $("#preview").attr("src"),
                                onCrop: function (res) {
                                    var loading = layer.msg('图片上传中...', { icon: 16, shade: 0.01, time: 0 });
                                    os.ajax({
                                        type: "post",
                                        url: "/api/lisence_ajax/user_avatar_crop",
                                        data: { data: res },
                                        dataType: "json",
                                        beforeSend: function (formData, jqForm, options) { },
                                        success: function (data, textStatus) {
                                            layer.close(loading);
                                            if (data.status == 1) {
                                                layer.msg('头像上传成功！', { icon: 1, time: 2000}, function () {
                                                    $("#preview").attr("src", data.avatar);
                                                });
                                            } else {
                                                layer.alert(data.msg);
                                            }
                                        },
                                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                                            layer.close(loading);
                                            layer.alert('状态：' + textStatus + '；出错提示：' + errorThrown, { icon: 5 });
                                        },
                                        complete: function (XMLHttpRequest, textStatus) { },
                                        timeout: 20000
                                    });
                                    return false;
                                }
                            });
                        });
                    });
                </script>
                <!--/设置头像-->
            }
            else if (action == "invite")
            {
                <!--邀请码-->
                <div class="sub-tit">
                    <a class="add" href="javascript:;">
                        <i class="fa fa-reply"></i>申请邀请码
                    </a>
                    <ul>
                        <li class="selected">
                            <a href="javascript:;">我的邀请码</a>
                        </li>
                    </ul>
                </div>
                <div class="table-wrap">
                    <div class="msg-box">
                        <i class="iconfont icon-tip"></i>
                        <p>您购买的邀请码会在失效之后由系统定时清理，不会长期驻留在列表中。</p>
                    </div>
                    <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                        <thead>
                            <tr>
                                <th lay-data="{checkbox:true}"></th>
                                <th lay-data="{field:'str_code',templet: '#str_code'}">邀请码</th>
                                <th lay-data="{field:'add_time'}">申请时间</th>
                                <th lay-data="{field:'eff_time'}">过期时间</th>
                                <th lay-data="{field:'count'}">已使用次数</th>
                                <th lay-data="{field:'status'}">状态</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <script type="text/html" id="str_code">
                    {{d.str_code}} &nbsp;
                    <a href="javascript:;" onclick="copyText('邀请码：{{d.str_code}}');">[复制]</a>
                </script>
                <script type="text/javascript">
                    layui.use(['table', 'myaspx'], function () {
                        var table = layui.table, os = layui.myaspx;

                        // 渲染表格
                        os.dataBind('/api/lisence_ajax/get_user_invite_list');

                        $(".add").click(function () {
                            os.clickSubmit('/api/lisence_ajax/user_invite_code');
                        })
                    });
                </script>
                <!--/邀请码-->
            }
        </div>
    </div>
    <!--/页面左边-->
</div>
@section Scripts{

}